﻿using UnityEditor;
using UnityEngine;

/// <summary>
/// 编译状态下导入脚本或者资源 则停止运行 防止崩溃 
/// </summary>
[InitializeOnLoad]
public class EditorCompilingStop
{
    static bool lastPlayingState;

    static EditorCompilingStop()
    {
        EditorApplication.update += onEditorUpdate;
    }

    private static void onEditorUpdate()
    {
        if (EditorApplication.isPlaying && EditorApplication.isCompiling)
            EditorApplication.isPlaying = false;
    }
}